<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>等你回家</title>
    <!-- Favicon -->
    <link rel="icon" href="<%=path%>/web/static/images/favicon.png" type="image/png" sizes="32x32">
    <link href="<%=path%>/web/index/css/inc.css" rel="stylesheet" type="text/css" media="all" />


    <link href="<%=path %>/web/index/css/style.css" rel="stylesheet" type="text/css" media="all" />
    <link rel="stylesheet" href="<%=path%>/web/static/css/bootstrap.min.css">
    <link rel="stylesheet" href="<%=path%>/web/static/css/style.css">
    <!-- Google font -->
</head>

<body>
<!--header-start -->
<div class="banner-in1">
    <div class="container1">
        <h6>寻亲登记 / <span>家寻宝贝</span></h6>
    </div>
</div>
<!--header-->
<div class="header1">
    <div class="container1">
        <div class="logo1">
            <a href="index.html"><img src="<%=path %>/web/index/images/logo.png" alt=" " /></a>
        </div>
        <div class="top-nav1">
            <span class="menu1"> </span>
            <ul>
                <li><a href="<%=path%>/web/index" class="scroll">首页 </a></li>
                <li class="active1"><a href="<%=path %>/web/information/chooseType" class="scroll">你在哪儿</a></li>
                <li><a href="<%=path %>/web/information/informationList?lostTypeId=0" class="scroll">我想回家</a></li>
                <li><a href="<%=path %>/web/blogger/blog" class="scroll">日志论坛</a></li>
                <li><a href="<%=path %>/web/task/releaseTask" class="scroll">任务列表</a></li>
                <c:if test="${empty(sessionScope.userinfo)}" var="result">
                    <li><a href="<%=path %>/web/userinfo/register" class="scroll">注册</a>|<a href="<%=path %>/web/userinfo/login" class="scroll">登录</a></li>
                </c:if>
                <c:if test="${not result}">
                    <li><a href="contact.html" class="scroll">加入我们</a></li>
                    <c:if test="${(sessionScope.userinfo.username eq '')||(sessionScope.userinfo.username eq NULL)}" var="result">
                        <span style="color:white">欢迎<a style="color: white" href="">${sessionScope.userinfo.phone}</a></span>
                    </c:if>
                    <c:if test="${not result}">
                        <span style="color:white">欢迎<a style="color: white" href="">${sessionScope.userinfo.username}</a></span>
                    </c:if>
                    <span style="color: white">|</span>

                    <span style="color:white"><a style="color: white" href="<%=path %>/web/userinfo/logout">注销</a></span>
                    <span style="color: white">|</span>
                    <label><img style="width:30px;height: 30px" src="<%=path %>/web/uploadImages/${sessionScope.userinfo.pic}"></label>
                </c:if>
            </ul>
<%--            <!--script-->--%>
<%--            <script>--%>
<%--                $("span.menu").click(function(){--%>
<%--                    $(".top-nav ul").slideToggle(500, function(){--%>
<%--                    });--%>
<%--                });--%>
<%--            </script>--%>
        </div>
        <div class="clearfix1"> </div>
    </div>
</div>



<main class="main-content-area clearfix">
    <div class="post-job-area pb-100 pt-100">
        <div class="container">
            <div class="row">
                <div class="col-md-12">
                    <div class="lost-type post-form form-bg" style="border-bottom: #979797 1px solid;">
                        <ul>
                            <li>1.选择登记类型</li>
                            <li class="select">2.填写信息登记</li>
                            <li>3.完成登记</li>
                        </ul>
                    </div>
                    <div class=" post-form form-bg">
                        <div class="info-title mb-3">
                            <h3>提交内容</h3>
                        </div>
                        <div class="row">
                            <div class="col-md-12">

                                <c:if test="${empty requestScope.information}" var="result">
                                <form action="<%=path%>/web/information/findPersons" method="POST"   id="register" enctype="multipart/form-data">
                                    <input type="hidden" value="${param.lostTypeId}" name="lostTypeId">
                                    <div class="form-row">
                                        <div class="form-group col-md-12">
                                            <label for="name">失踪人姓名:</label>
                                            <input type="text"  name="name"    id="name" placeholder="">
                                            <input type="hidden" name="userinfoId" value="${sessionScope.userinfo.id}"/>
                                            <span id="names"></span>
                                        </div>
                                    </div>


                                    <div class="form-row">
                                        <div class="form-group col-md-12">
                                            <label for="name">失踪人身高:</label>
                                            <input type="text"  name="lostHeight" id="lost_height">(cm)
                                            <span style="color:red;" id="height"></span>
                                        </div>
                                    </div>

                                    <div class="form-row">
                                        <div class="form-group col-md-12">
                                            <label for="name">失踪人体重:</label>
                                            <input type="text"  name="lostWeight"  id="lost_weight">(kg)
                                            <span style="color:red" id="weights"></span>
                                        </div>
                                    </div>





                                    <div class="form-row">
                                        <div class="form-group col-md-12">
                                            <label for="name">失踪人性别:</label>
                                            <INPUT checked name="sex" type="radio" value="男"/>男
                                            <INPUT name="sex" type="radio" value="女"/>女
                                        </div>
                                    </div>

                                    <div class="form-row">
                                        <div class="form-group col-md-12">
                                            <label for="name">失踪人血型:</label>
                                            <INPUT checked name="blood" type="radio" value="A"/>.A型
                                            <INPUT name="blood" type="radio" value="B"/>.B型
                                            <INPUT name="blood" type="radio" value="AB"/>.AB型
                                            <INPUT name="blood" type="radio" value="O"/>.O型
                                            <INPUT name="blood" type="radio" value="其它"/>.其它
                                        </div>
                                    </div>

                                    <div class="form-row">
                                        <div class="form-row">
                                            <div class="form-group col-md-12">
                                                <label style="margin-left:10px">失踪人出生年月日</label>
                                                <input type="date" id="borntime" name="birthday">
                                            </div>
                                        </div>
                                    </div>

                                    <div class="form-row">
                                        <div class="form-group col-md-12">
                                            <label >失踪人籍贯</label>
                                            <select id="province" class="form-control custom-select" style="width:150px;" name="provinceId" >
                                                <c:forEach items="${requestScope.root}" var="area">
                                                    <option value="${area.areaId}">${area.areaName}</option>
                                                </c:forEach>
                                            </select >
                                            <select data-id="0" id="city" name="cityId" class="form-control custom-select" style="width:150px; ">
                                            </select>
                                            <select data-id="0" id="area" name="areaId" class="form-control custom-select" style="width:150px; ">
                                            </select>
                                        </div>
                                    </div>


                                    <div class="form-row" style="margin-top: 20px;">
                                        <div>
                                            <div class="form-group col-md-12">
                                                <label style="margin-left: -10px">失踪人走失时间</label>
                                                <input type="date" id="begindate" name="lostDateStart">
                                            </div>
                                        </div>
                                        <div><label >到</label>&nbsp;&nbsp;&nbsp;&nbsp;
                                            <input type="date" id="enddate" name="lostDateEnd">
                                        </div>(具体时间前后选择一致)
                                        <span style="color:red" id="xianshi"></span>
                                    </div>

                                    <div class="form-row">
                                        <div class="form-group col-md-12">
                                            <label for="name">失踪人照片:</label>
                                            <input type="file" id="pic1" name="pic1"/>
                                            <span style="color:red" id="pic"></span>
                                        </div>
                                    </div>
                                    <!-- 显示图片的DIV-->
                                    <div style="border:1px solid black; width: 250px;height:200px;margin-bottom: 10px;">
                                        <img style="width: 248px;height: 198px;" id="showPic" >
                                    </div>
                                    <!-- /显示图片的DIV-->

                                    <div class="form-row">
                                        <div class="form-group col-md-12">
                                        <label >走失地点:</label>
                                        <textarea class="form-control" name="lostPlace"  id="lost_place" rows="3"></textarea>
                                            <span style="color:red" id="lost_places"></span>
                                        </div>
                                    </div>

                                    <div class="form-row">
                                        <div class="form-group col-md-12">
                                            <label for="name">失踪人着装:</label>
                                            <textarea class="form-control" name="lostClothes"  id="lost_clothes" rows="3"></textarea>
                                            <span style="color:red" id="clothess"></span>
                                        </div>
                                    </div>


                                    <div class="form-row">
                                        <div class="form-group col-md-12">
                                            <label>失踪经过:</label>
                                            <textarea class="form-control" name="lostProcess" id="lost_process" rows="3"></textarea>
                                            <span style="color:red" id="lost_processs"></span>
                                        </div>
                                    </div>

                                    <div class="form-row">
                                        <div class="form-group col-md-12">
                                        <label>失踪人体貌特征:</label>
                                        <textarea class="form-control" name="lostRemark"  id="remark"  rows="3"></textarea>
                                            <span style="color:red" id="remarks"></span>
                                        </div>
                                    </div>
                                    <div class="info-title mb-3">
                                        <h3>联系人完善信息</h3>
                                    </div>
                                    <div class="form-row">
                                        <div class="form-group col-md-12">
                                            <label ><span style="color: red;"></span>联系人姓名</label>
                                            <input type="text" id="contactName" name="contactName">
                                            <span style="color:red;" id="contactNames"></span>
                                        </div>
                                    </div>
                                    <div class="form-row">
                                        <div class="form-group col-md-12">
                                            <label for="contactNumber">联系人电话:</label>
                                            <input type="text" name="contactNumber" id="contactNumber" value="">
                                            <span id="contactNumbers" style="color: red" ></span>
                                        </div>
                                    </div>
                                    <button type="submit" class="btn btn-primary job-post-btn btn-lg btn-block ">发布</button>
                                </form>
                                </c:if>

                                <c:if test="${not result}">
                                    <form action="<%=path%>/web/information/updateByInformationId1" method="POST"   id="register" enctype="multipart/form-data">
                                        <input type="hidden" value="${requestScope.information.lostTypeId}" name="lostTypeId">
                                        <input type="hidden" value="${requestScope.information.id}" name="id">
                                        <div class="form-row">
                                            <div class="form-group col-md-12">
                                                <label for="name">失踪人姓名:</label>
                                                <input type="text"  name="name"    id="name" placeholder="" value="${requestScope.information.name}">
                                                <span id="names"></span>
                                            </div>
                                        </div>


                                        <div class="form-row">
                                            <div class="form-group col-md-12">
                                                <label for="name">失踪人身高:</label>
                                                <input type="text"  name="lostHeight" id="lost_height" value="${requestScope.information.lostHeight}">(cm)
                                                <span style="color:red;" id="height"></span>
                                            </div>
                                        </div>

                                        <div class="form-row">
                                            <div class="form-group col-md-12">
                                                <label for="name">失踪人体重:</label>
                                                <input type="text"  name="lostWeight"  id="lost_weight" value="${requestScope.information.lostWeight}">(kg)
                                                <span style="color:red" id="weights"></span>
                                            </div>
                                        </div>





                                        <div class="form-row">
                                            <div class="form-group col-md-12">
                                                <label for="name">失踪人性别:</label>
                                                <c:if test="${requestScope.information.sex eq '男'}">
                                                    <INPUT checked name="sex" type="radio" value="男"/>男
                                                    <INPUT name="sex" type="radio" value="女"/>女
                                                </c:if>
                                                <c:if test="${requestScope.information.sex eq '女'}">
                                                    <INPUT name="sex" type="radio" value="男"/>男
                                                    <INPUT checked name="sex" type="radio" value="女"/>女
                                                </c:if>
                                            </div>
                                        </div>

                                        <div class="form-row">
                                            <div class="form-group col-md-12">
                                                <label for="name">失踪人血型:</label>
                                                <c:if test="${requestScope.information.blood eq 'A'}">
                                                <INPUT checked name="blood" type="radio" value="A"/>.A型
                                                <INPUT name="blood" type="radio" value="B"/>.B型
                                                <INPUT name="blood" type="radio" value="AB"/>.AB型
                                                <INPUT name="blood" type="radio" value="O"/>.O型
                                                <INPUT name="blood" type="radio" value="其它"/>.其它
                                                </c:if>
                                                <c:if test="${requestScope.information.blood eq 'B'}">
                                                    <INPUT name="blood" type="radio" value="A"/>.A型
                                                    <INPUT checked name="blood" type="radio" value="B"/>.B型
                                                    <INPUT name="blood" type="radio" value="AB"/>.AB型
                                                    <INPUT name="blood" type="radio" value="O"/>.O型
                                                    <INPUT name="blood" type="radio" value="其它"/>.其它
                                                </c:if>
                                                <c:if test="${requestScope.information.blood eq 'AB'}">
                                                    <INPUT name="blood" type="radio" value="A"/>.A型
                                                    <INPUT name="blood" type="radio" value="B"/>.B型
                                                    <INPUT checked name="blood" type="radio" value="AB"/>.AB型
                                                    <INPUT name="blood" type="radio" value="O"/>.O型
                                                    <INPUT name="blood" type="radio" value="其它"/>.其它
                                                </c:if>
                                                <c:if test="${requestScope.information.blood eq 'O'}">
                                                    <INPUT name="blood" type="radio" value="A"/>.A型
                                                    <INPUT name="blood" type="radio" value="B"/>.B型
                                                    <INPUT name="blood" type="radio" value="AB"/>.AB型
                                                    <INPUT checked name="blood" type="radio" value="O"/>.O型
                                                    <INPUT name="blood" type="radio" value="其它"/>.其它
                                                </c:if>
                                                <c:if test="${requestScope.information.blood eq '其他'}">
                                                    <INPUT name="blood" type="radio" value="A"/>.A型
                                                    <INPUT name="blood" type="radio" value="B"/>.B型
                                                    <INPUT name="blood" type="radio" value="AB"/>.AB型
                                                    <INPUT name="blood" type="radio" value="O"/>.O型
                                                    <INPUT checked name="blood" type="radio" value="其它"/>.其它
                                                </c:if>
                                            </div>
                                        </div>

                                        <div class="form-row">
                                            <div class="form-row">
                                                <div class="form-group col-md-12">
                                                    <label style="margin-left:10px">失踪人出生年月日</label>
                                                    <input type="date" id="borntime" name="birthday" value="${requestScope.information.birthday}">
                                                </div>
                                            </div>
                                        </div>

                                        <div class="form-row">
                                            <div class="form-group col-md-12">
                                                <label >失踪人籍贯</label>
                                                <select id="province" class="form-control custom-select" style="width:150px;" name="provinceId">
                                                    <c:forEach items="${requestScope.provinces}" var="province">
                                                        <c:if test="${province.areaId eq requestScope.provinceId}" var="province1">
                                                            <option value="${province.areaId}" selected>${province.areaName}</option>
                                                        </c:if>
                                                        <c:if test="${not province1}">
                                                            <option value="${province.areaId}">${province.areaName}</option>
                                                        </c:if>
                                                    </c:forEach>
                                                </select >
                                                <select data-id="${requestScope.information.cityId}" id="city" name="cityId" class="form-control custom-select" style="width:150px; ">
                                                </select>
                                                <select data-id="${requestScope.information.areaId}" id="area" name="areaId" class="form-control custom-select" style="width:150px; ">
                                                </select>
                                            </div>
                                        </div>


                                        <div class="form-row" style="margin-top: 20px;">
                                            <div>
                                                <div class="form-group col-md-12">
                                                    <label style="margin-left: -10px">失踪人走失时间</label>
                                                    <input type="date" id="begindate" name="lostDateStart" value="${requestScope.information.lostDateStart}">
                                                </div>
                                            </div>
                                            <div><label >到</label>&nbsp;&nbsp;&nbsp;&nbsp;
                                                <input type="date" id="enddate" name="lostDateEnd" value="${requestScope.information.lostDateEnd}">
                                            </div>(具体时间前后选择一致)
                                            <span style="color:red" id="xianshi"></span>
                                        </div>

                                        <div class="form-row">
                                            <div class="form-group col-md-12">
                                                <label for="name">失踪人照片:</label>
                                                <input type="file" id="pic1" name="pic1" value="${requestScope.information.pic}"/>
                                                <span style="color:red" id="pic"></span>
                                            </div>
                                        </div>

                                        <!-- 显示图片的DIV-->
                                        <div style="border:1px solid black; width: 250px;height:200px;margin-bottom: 10px;">
                                            <img style="width: 248px;height: 198px;" id="showPic" src="<%=path %>/web/uploadImages/${information.pic}">
                                        </div>
                                        <!-- /显示图片的DIV-->
                                        <div class="form-row">
                                            <div class="form-group col-md-12">
                                                <label >走失地点:</label>
                                                <textarea class="form-control" name="lostPlace"  id="lost_place" rows="3">${requestScope.information.lostPlace}</textarea>
                                                <span style="color:red" id="lost_places"></span>
                                            </div>
                                        </div>

                                        <div class="form-row">
                                            <div class="form-group col-md-12">
                                                <label for="name">失踪人着装:</label>
                                                <textarea class="form-control" name="lostClothes"  id="lost_clothes" rows="3">${requestScope.information.lostClothes}</textarea>
                                                <span style="color:red" id="clothess"></span>
                                            </div>
                                        </div>


                                        <div class="form-row">
                                            <div class="form-group col-md-12">
                                                <label>失踪经过:</label>
                                                <textarea class="form-control" name="lostProcess" id="lost_process" rows="3">${requestScope.information.lostProcess}</textarea>
                                                <span style="color:red" id="lost_processs"></span>
                                            </div>
                                        </div>

                                        <div class="form-row">
                                            <div class="form-group col-md-12">
                                                <label>失踪人体貌特征:</label>
                                                <textarea class="form-control" name="lostRemark"  id="remark"  rows="3">${requestScope.information.lostRemark}</textarea>
                                                <span style="color:red" id="remarks"></span>
                                            </div>
                                        </div>
                                        <div class="info-title mb-3">
                                            <h3>联系人完善信息</h3>
                                        </div>
                                        <div class="form-row">
                                            <div class="form-group col-md-12">
                                                <label ><span style="color: red;"></span>联系人姓名</label>
                                                <input type="text" id="contactName" name="contactName" value="${requestScope.information.contactName}">
                                                <span style="color:red;" id="contactNames"></span>
                                            </div>
                                        </div>
                                        <div class="form-row">
                                            <div class="form-group col-md-12">
                                                <label for="contactNumber">联系人电话:</label>
                                                <input type="text" name="contactNumber" id="contactNumber" value="${requestScope.information.contactNumber}">
                                                <span id="contactNumbers" style="color: red" ></span>
                                            </div>
                                        </div>
                                        <button type="submit" class="btn btn-primary job-post-btn btn-lg btn-block ">发布</button>
                                    </form>
                                </c:if>

                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
</main>
<!--footer-area-start -->
<footer>
    <div class="footer" style="height: 230px;">
        <div class="container" style="margin-top: -40px;">
            <p style="font-size: 15px;"><span style="font-size: 20px;">等你回家</span><span >邮箱:1111111@163.com</span> 电话:0532—85025005</p>
            <p class="footer-class" style="font-size:15px;margin-top: -75px;">地址:山东省青岛市市南区中联创意广场B1栋三楼 <a href="http://w3layouts.com/" target="_blank">万码学堂</a></p>
            <p class="footer-class" style="font-size:15px;margin-top: -60px;text-transform: none">Copyright © 2019 www.dengnihuijia.com All rights Reserved.</p>
        </div>
    </div>
</footer>

<script src="<%=path%>/web/static/js/modules/jquery-3.4.1.min.js"></script>
</body>

</html>
<script>
    $(function(){
        <!-- 图片上传加显示-->
        var input=document.getElementById("pic1");
        input.onchange = function() {
            var rd = new FileReader();//创建文件读取对象
            var files = input.files[0];//获取file组件中的文件
            rd.readAsDataURL(files);//文件读取装换为base64类型
            rd.onloadend = function (e) {
                //加载完毕之后获取结果赋值给img
                document.getElementById("showPic").src = this.result;
            }
        }
        <!-- /图片上传加显示-->

        var error_name=false;//判断姓名
        var error_sex=false;//判断性别
        var error_blood=false;//判断血型
        var error_lost_height=false;//判断走失身高
        var error_pic=false;//判断图片
        var error_birthday=false//判断生日
        var error_lost_place=false;//判断走失地
        var error_lost_process=false;//判断走势经过
        var error_time = false;//判断丢失事件大小
        var error_lost_weight=false;//判断体重
        var error_lost_clothes=false;//判断着装
        var error_remark=false;//判断备注
        var error_contactName=false;//联系人姓名；
        var error_contactNumber=false;//联系人电话;


        $("#name").blur(function () {//失去焦点
            check_name();
        })
        $("#name").focus(function(){//获得焦点
         check_name1();
        })

        $("#lost_place").blur(function(){
            check_lost_place();
        })
        $("#lost_place").focus(function(){
            check_lost_place1();
        })
        $("#lost_height").blur(function(){//失去焦点
            check_lost_height();
        })
        $("#lost_height").focus(function(){//得到焦点
            check_lost_height1();
        })
        $("#lost_process").blur(function(){
            check_lost_process();
        })
        $("#lost_process").focus(function(){
            check_lost_process1();
        })

        $("#enddate").blur(function () {//丢失时间失去焦点事件
            check_user_time();
        })

        $("#lost_weight").blur(function () {//体重丢失焦点判断
            check_lost_weight();
        })

        $("#lost_clothes").blur(function () {//着装丢失焦点判断
            check_lost_clothes();
        })

        $("#remark").blur(function () {//备注丢失焦点判断
            check_remark();
        })

        $("#contactName").blur(function () {//联系人姓名失去焦点事件
            check_contactName();
        })
        $("#contactNumber").blur(function () {//联系人电话失去焦点事件
            check_contactNumber();
        })
        $("#pic1").blur(function () {//图片失去焦点
            check_pic();
        })

        function check_pic(){//照片失去焦点
            var pic1=$("#pic1").val();
            if(pic1==""){
                $("#pic").html("(照片不能为空)")
                $("#pic").css("color","red");
                error_pic=true;
            }else{
                $("#pic").html("");
                error_pic = false;
            }
        }

        function check_lost_weight() {//体重失去焦点事件
            var rs = /^[1-9]\d{0,2}(\.\d{0,2})?$/;
            var weight = $("#lost_weight").val();
            if (weight =="") {
                $("#weights").html("(失踪人体重不能为空)");
                $("#weights").css("color","red");
                error_lost_weight = true;
            } else {
                if (rs.test(weight)) {
                    $("#weights").html("");
                    $("#weights").css("color", "green");
                    error_lost_weight = false;
                } else {
                    $("#weights").html("(失踪人体重格式不正确)");
                    $("#weights").css("color", "red");
                    error_lost_weight = true;
                }
            }
        }


        function check_lost_clothes() {//失去焦点事件
            var clothes = $("#lost_clothes").val();
            if (clothes =="") {
                $("#clothess").html("(失踪人着装不能为空)");
                error_lost_clothes = true;
            }
            else{
                $("#clothess").html("");
                error_lost_clothes = false;
            }
        }




        function check_remark() {// 失去焦点
            var remark = $("#remark").val();
            if (remark == "") {
                $("#remarks").html("(失踪人貌特征不能为空)");
                error_remark = true;
            }else{
                $("#remarks").html("");
                error_remark = false;
            }
        }

        function check_name(){//失去焦点
             var rs=/^([\u4e00-\u9fa5]){2,7}$/;
             var name=$('#name').val();
             if(name==""){
                 $("#name").next().html("(失踪人姓名不能为空)");
                 $("#names").css("color", "red");
                 $('#name').next().show();
                 error_name=true;
             }

             else {
                 if (rs.test(name)) {
                     $("#name").next().hide();
                     error_name = false;
                 } else {
                     $("#name").next().html("失踪人姓名格式不正确");
                     $("#names").css("color", "red");
                     $("#name").next().show();
                     error_name = true;
                 }
             }
         }

         function check_name1() {//获得焦点
             $("#name").next().html("(请输入失踪人的姓名)");
             $("#names").css("color", "green");
             $('#name').next().show();
         }


        function check_lost_height1() {//身高得到焦点事件
            $("#lost_height").next().html("(两位或三位阿拉伯数字)");
            $("#height").css("color", "green")
            $('#lost_height').next().show();
        }

        function check_lost_height() {//身高失去焦点事件
            var rs = /^[1-9]\d{1,2}$/;
            var height= $('#lost_height').val();
            if (height=="") {
                $("#height").html("(失踪人身高不能为空)");
                $("#height").css("color", "red");
                error_lost_height = true;
            } else {
                if (rs.test(height)) {
                    $("#lost_height").next().hide();
                    error_lost_height = false;
                } else {
                    $("#lost_height").next().html("(失踪人身高格式不正确)");
                    $("#height").css("color", "red");
                    $('#lost_height').next().show();
                    error_lost_height = true;
                }
            }

        }



        function check_lost_place(){//走失地失去焦点事件
            var place = $("#lost_place").val();
            if (place =="") {
                $("#lost_places").html("(失踪人走失地不能为空)");
                error_lost_place= true;
            }else{
                $("#lost_places").html("");
                error_lost_place= false;
            }

        }



        function check_lost_process(){// 失去焦点
            var place = $("#lost_process").val();
            if (place =="") {
                $("#lost_processs").html("(失踪人走失过程不能为空)");
                error_lost_process= true;
            }else{
                $("#lost_processs").html("");
                error_lost_process= false;
            }
        }

        function check_user_time() {//丢失时间范围失去焦点事件
            var begindata = $("#begindate").val();
            var date = Date.parse(begindata);
            var enddata=$("#enddate").val();
            var dates = Date.parse(enddata);
            if(date<=dates)
            {
                $("#xianshi").html("");
                error_time = false;
            }
            else
            {

                    $("#xianshi").html("(时间格式错误请重新选择！)");
                    error_time = true;

            }

        }


        function check_contactName() {//联系人姓名失去焦点事件
            var contactName=$("#contactName").val();
            if(contactName=="")
            {
                $("#contactNames").html("(联系人不能为空)");
                $("#contactNames").css("color","red");
                error_contactName=true;
            }
            else{
                $("#contactNames").html("");
                error_contactName=false;
            }
        }
        function check_contactNumber() {//联系人电话失去焦点事件
            var contactNumber=$("#contactNumber").val();
            var zz=/^1[34578]\d{9}$/;
            if(contactNumber=="")
            {
                $("#contactNumbers").html("(联系电话不能为空)");
                $("#contactNumbers").css("color","red");
                error_contactName=true;
            }
            else if(!zz.test(contactNumber)){
                $("#contactNumbers").html("(手机号格式错误)");
                error_contactName=true;
            }
            else{
                $("#contactNumbers").html("");
                error_contactName=false;
            }

        }




        $("#register").submit(function () {
            check_name();
            check_lost_height();
            check_lost_place();
            check_lost_process();
            check_user_time();
            check_lost_weight();
            check_lost_clothes();
            check_pic();
            check_remark();
            check_contactName();
            check_contactNumber();
            if (error_name == false && error_lost_height == false && error_lost_place == false && error_lost_process == false  && error_time == false && error_lost_weight == false && error_lost_clothes == false && error_remark == false&& error_contactName==false && error_contactNumber==false && error_pic==false) {
                return true;
            } else {
                return false;
            }
        })


        initCities();
        $("#province").change(function(){
            initCities()
        })
        $("#city").change(function(){
            initAreas()
        })
    })





    function initCities(){
        var provinceId = $("#province").val();
        $("#city").empty();
        $("#area").empty();
        var cityId = $("#city").data("id");
        var areaId = $("#area").data("id")
        $.ajax({
            url: "${pageContext.request.contextPath}/web/information/cities",
            data:{"areaId":provinceId},
            type:"get",
            dataType:"json",
            success:function(cities) {
                if(cityId==0&&areaId==0){
                    for(var i=0;i<cities.length;i++)
                    {
                        $("#city").append("<option value=\""+cities[i].areaId+"\">"+cities[i].areaName+"</option>")
                    }
                    $.getJSON("${pageContext.request.contextPath}/web/information/cities",{areaId:$("#city").val()}, function (cities) {
                        for(var i=0;i<cities.length;i++)
                        {
                            $("#area").append("<option value=\""+cities[i].areaId+"\">"+cities[i].areaName+"</option>")
                        }
                    });
                }else{
                    for(var i=0;i<cities.length;i++)
                    {
                        if(cityId==cities[i].areaId){
                            $("#city").append("<option selected value=\""+cities[i].areaId+"\">"+cities[i].areaName+"</option>")
                        }else{
                            $("#city").append("<option value=\""+cities[i].areaId+"\">"+cities[i].areaName+"</option>")
                        }

                    }
                    $.getJSON("${pageContext.request.contextPath}/web/information/cities",{areaId:$("#city").val()}, function (cities) {
                        for(var i=0;i<cities.length;i++)
                        {
                            if(areaId==cities[i].areaId){
                                $("#area").append("<option selected value=\""+cities[i].areaId+"\">"+cities[i].areaName+"</option>")
                            }else{
                                $("#area").append("<option value=\""+cities[i].areaId+"\">"+cities[i].areaName+"</option>")
                            }

                        }
                    });
                }
            }
        });
    }
    function initAreas() {
        var areaId = $("#city").val();
        $("#area").empty();
        $.ajax({
            url:"${pageContext.request.contextPath}/web/information/cities",
            data:{"areaId":areaId},type:"get",dateType:"json",
            success:function (mes) {
                for (var i = 0; i < mes.length; i++) {
                    $("#area").append("<option value=\"" + mes[i].areaId + "\">" + mes[i].areaName + "</option>")
                }
            }
        })
    }



</script>
